<template>
	<view>
		<input class="uni-input" type="text" value="" v-model="email" placeholder="输入邮箱"/>
		<input class="uni-input" type="text" value="" v-model="password" placeholder="输入密码"/>
		<view class="py-2 px-3">
			<button class="bg-main text-white" style="border-radius: 50rpx; border: 0;" type="primary" @click="submit" :disabled="disabled">设置</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
			  email:'',
			  password:''	  
			}
		},
		computed:{
			disabled(){
				return this.email == '' || this.password == ''
			}
		},
		methods: {
			checked(){
			  let rule = /^[A-Za-z\d]+([-_.][A-Za-z\d]+)*@([A-Za-z\d]+[-.])+[A-Za-z\d]{2,4}$/
			  return rule.test(this.email)
			},
			submit(){
				if(!this.checked()){
					uni.showToast({
						title:"邮箱格式错误",
						icon:"none"
					})
					return;
				}
				this.$R.put("/system/user/setEmail",{password:this.password,email:this.email}).then(res=>{
						uni.showToast({
							title:res.msg,
							icon:'none'
						})	
				})
			}
		}
	}
</script>

<style>

</style>
